package com.qing.aclservice.controller;


import com.qing.aclservice.entity.pojo.AclPermission;
import com.qing.aclservice.service.AclPermissionService;
import com.qing.servicebase.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 权限 前端控制器
 * </p>
 *
 * @author Yjx
 * @since 2022-09-19
 */
@RestController
@RequestMapping("/aclservice/permission")
public class AclPermissionController {
    @Autowired
    private AclPermissionService permissionService;
    //获取全部菜单
    @GetMapping("/getAll")
    public ResponseResult indexAllPermission() {
        List<AclPermission> list = permissionService.queryAllMenu();
        return ResponseResult.ofSuccess(list);
    }

    @DeleteMapping("/remove/{id}")
    public ResponseResult remove(@PathVariable String id) {
        permissionService.removeChildById(id);
        return ResponseResult.ofSuccess(null);
    }

    @PostMapping("/doAssign")
    public ResponseResult doAssign(String roleId,String[] permissionId) {
        permissionService.saveRolePermissionRealtionShip(roleId,permissionId);
        return ResponseResult.ofSuccess(null);
    }
}

